function returnInt(a) {
	if (a != null && a !== "" && a != undefined) {
		return parseInt(a);
	} else {
		return 0;
	}
}


function returnTopData(list) {
	var dataArr = new Array();
	if (list.hasOwnProperty("resource")) {
		dataArr.push({
			value : ifGreaterThanZero(parseInt(list.resource)),
			name : '查看资源'
		});
	}
	if (list.hasOwnProperty("activity")) {
		dataArr.push({
			value : ifGreaterThanZero(parseInt(list.activity)),
			name : '参加活动'
		});
	}
	
	if (list.hasOwnProperty("answerQuestion")) {
		dataArr.push({
			value : ifGreaterThanZero(parseInt(list.answerQuestion)),
			name : '提出答疑'
		});

	}
	return dataArr;

}
//返回积分头部数组
function returnUserPointStatisticsTopData(list) {
	var dataArr = new Array();
	if (list.hasOwnProperty("hdresource")) {
		dataArr.push({
			value : list.hdresource.points,
			name : list.hdresource.content_type
		});
	}
	if (list.hasOwnProperty("tests")) {
		dataArr.push({
			value : list.tests.points,
			name : list.tests.content_type
		});
	}
	if (list.hasOwnProperty("works")) {
		dataArr.push({
			value : list.works.points,
			name : list.works.content_type
		});
	}
	if (list.hasOwnProperty("survey")) {
		dataArr.push({
			value : list.survey.points,
			name : list.survey.content_type
		});
	}
	if (list.hasOwnProperty("sitenow")) {
		dataArr.push({
			value : list.sitenow.points,
			name : list.sitenow.content_type
		});
	}
	if (list.hasOwnProperty("answerQuestion")) {
		dataArr.push({
			value : list.answerQuestion.points,
			name : list.answerQuestion.content_type
		});

	}
	if (list.hasOwnProperty("discuss")) {
		dataArr.push({
			value : list.discuss.points,
			name : list.discuss.content_type
		});

	}
	return dataArr;

}
//组件我的积分底部数组
function returnUserPointStatisticsDownData(list) {
	var dataArr = new Array();
	if (list.hasOwnProperty("hdresource")) {
	    list.hdresource['type']="hdresource"
		dataArr.push(list.hdresource);
	}
	if (list.hasOwnProperty("tests")) {
	    list.tests['type']="tests"
		dataArr.push(list.tests);
	}
	if (list.hasOwnProperty("works")) {
	 list.works['type']="works"
		dataArr.push(list.works);
	}
	if (list.hasOwnProperty("discuss")) {
	   list.discuss['type']="discuss"
	   dataArr.push(list.discuss);

	}
	if (list.hasOwnProperty("survey")) {
	    list.survey['type']="survey"
		dataArr.push(list.survey);
	}
	if (list.hasOwnProperty("sitenow")) {
	 list.sitenow['type']="sitenow"
		dataArr.push(list.sitenow);
	}
	if (list.hasOwnProperty("answerQuestion")) {
	   list.answerQuestion['type']="answerQuestion"
		dataArr.push(list.answerQuestion);

	}
	
	
	return dataArr;

}
//根据type返回颜色
function judgeTypeReturnColor(data){
	if (data.type == 'hdresource') {
      return 0;
	} else if (data.type == 'tests') {
      return 1;
	} else if (data.type == 'works') {
	 return 2;
	} else if (data.type == 'survey') {
	  return 3;
	} else if (data.type == 'sitenow') {
     return 4;
	} else if (data.type == 'answerQuestion') {
	 return 5;		
	}else if(data.type == 'discuss'){
	 return 6;
	}


}
//判断是左右
function judgeDoubleStr(i) {
	if (i % 2 == 0) {
		return 'right-cell'
	} else {
		return 'left-cell'
	}

}
//根据积分所属类型返回相应的html
function TypeReturnStr(data,i,boder_color) {
	if (data.type == 'hdresource') {
  return '<div id="resource_chart' + (i + 1) + '" class="sub-chart"></div>'+
	      '<div class="sub-title-div">'+
	      '<p class="sub-title">'+
			   '当前发布<span class="sub-tag-span font_color'+boder_color+'">'+data.allnum+'</span>个'+
			'</p>'+
			'<p class="sub-title">'+
				'已学习<span class="sub-tag-span font_color'+boder_color+'">'+data.partakenum+'</span>个'+
			'</p>'+
		'</div>';
	} else if (data.type == 'tests') {
 return '<div id="resource_chart' + (i + 1) + '" class="sub-chart"></div>'+
	      '<div class="sub-title-div">'+
	      '<p class="sub-title">'+
			   '当前有效<span class="sub-tag-span font_color'+boder_color+'">'+data.allnum+'</span>个'+
			'</p>'+
			'<p class="sub-title">'+
				'完成<span class="sub-tag-span font_color'+boder_color+'">'+data.partakenum+'</span>个'+
			'</p>'+
		'</div>';
	} else if (data.type == 'works') {
	 return '<div id="resource_chart' + (i + 1) + '" class="sub-chart"></div>'+
	      '<div class="sub-title-div">'+
	      '<p class="sub-title">'+
			   '总共发布<span class="sub-tag-span font_color'+boder_color+'">'+data.allnum+'</span>个'+
			'</p>'+
			'<p class="sub-title">'+
				'提交<span class="sub-tag-span font_color'+boder_color+'">'+data.partakenum+'</span>个'+
			'</p>'+
		'</div>';
	}else if(data.type == 'discuss'){
	
	 return '<div id="resource_chart' + (i + 1) + '" class="sub-chart"></div>'+
	      '<div class="sub-title-div">'+
		        '<p class="sub-title">'+
				   '总共发起<span class="sub-tag-span font_color'+boder_color+'">'+data.allnum+'</span>个'+
				'</p>'+
				'<p class="sub-title">'+
					'完成<span class="sub-tag-span font_color'+boder_color+'">'+data.partakenum+'</span>个,'+
					'发表<span class="sub-tag-span font_color'+boder_color+'">'+ifGreaterThanZero(data.count)+'</span>次'+
				'</p>'+
				'</div>';
	} else if (data.type == 'survey') {
	  return '<div id="resource_chart' + (i + 1) + '" class="sub-chart"></div>'+
	      '<div class="sub-title-div">'+
	      '<p class="sub-title">'+
			   '共有<span class="sub-tag-span font_color'+boder_color+'">'+data.allnum+'</span>项'+
			'</p>'+
			'<p class="sub-title">'+
				'参与<span class="sub-tag-span font_color'+boder_color+'">'+data.partakenum+'</span>项'+
			'</p>'+
		'</div>';
	} else if (data.type == 'sitenow') {
  return '<div id="resource_chart' + (i + 1) + '" class="sub-chart"></div>'+
	      '<div class="sub-title-div">'+
	      '<p class="sub-title">'+
			   '当前发布<span class="sub-tag-span font_color'+boder_color+'">'+data.allnum+'</span>次'+
			'</p>'+
			'<p class="sub-title">'+
				'已完成<span class="sub-tag-span font_color'+boder_color+'">'+data.partakenum+'</span>次'+
			'</p>'+
		'</div>';
	} else if (data.type == 'answerQuestion') {
	 return'<div id=""resource_chart" class="sub-chart">'+
				'<img class="left-icon" src="../../image/icon_yiwen.png">'+
		     '</div>'+
			 '<div class="sub-title-div">'+
	      '<p class="sub-title">'+
				'积分提问<span class="sub-tag-span font_color'+boder_color+'"></span>'+
			'</p>'+
			'<p class="sub-title">'+
					'热心解答<span class="sub-tag-span font_color'+boder_color+'">'+data.partakenum+'</span>次'+
			'</p>'+
		'</div>';
			
	
	
	}

}
	//判断积分正负
function judgePointsPositiveAndnegative(num){
	if(num>0){
		 return "+"+num;
	}else if(num<0){
		return num;
	}else{
		return num;
	}
		
}
//是否大于0
function ifGreaterThanZero(b) {
    var a=parseInt(b);
	if (a >= 0) {
		return a
	} else if (a < 0) {
		return 0;
	} else {
		return 0;
	}
	

}